<?php
session_start();
include("functions.php");
//echo "awmtkyf dkif;rS jukdqkdyg";

//echo "awmtkyf&dkif;rS jukdqkdyg\\";
//add_one_click_to_session($id,"goodbad");

$task = $_GET["t"];
if($task == "t")
{
	//this will actually insert
	//variables are encoded
	$word = $_GET["w"];
	$def = $_GET["d"];
	$example = $_GET["e"];
	$author = $_GET["a"];
	$formid = $_GET["f"];
	
	//put the translated words in db **************
	
	//echo "we gonna put things in the db:\n$word,$def,$example,$author";
	//echo "";
	insert_burmese_typings($word,$def,$example,$author,$formid);
	change_completed($formid,1); //completed 1 means..burglish entry has a burmese typing..not approved yet
	
	
	//$good_times = $_SESSION[$id."good"];
	
	
	$decoded_word = burmese_special_char_decoder($word);
	$decoded_word = htmlspecialchars($decoded_word, ENT_QUOTES);
	
	$decoded_def = burmese_special_char_decoder($def);
	$decoded_def = htmlspecialchars($decoded_def, ENT_QUOTES);
	
	$decoded_example = burmese_special_char_decoder($example);
	$decoded_example = htmlspecialchars($decoded_example, ENT_QUOTES);
	
	$decoded_author = burmese_special_char_decoder($author);
	$decoded_author = htmlspecialchars($decoded_author, ENT_QUOTES);
	
	$response= "$formid<form onsubmit=\"overlayclose('hidden_form$formid');return false\">
<table border=0 width=320>
<tr><td colspan=\"2\" ><p class=textdark>Thanks for your help. Other viewers will look at your burmese typing and if 3 out of 5 viewers think that its' ok, then it will become permanent.</p></td></tr>
<tr><td class=textdark width=20%>Word:</td><td class=textdarkb>$decoded_word</input></td></tr>
<tr><td class=textdark>Definition:</td><td class=textdarkb>$decoded_def</textarea></td></tr>
<tr><td class=textdark>Example:</td><td class=textdarkb>$decoded_example</td></tr>
<tr><td class=textdark>Author:</td><td class=textdarkb>$decoded_author</td></tr>

</table>
			</form><div align=\"right\"><a href=\"#\" onClick=\"overlayclose('hidden_form$formid'); return false\"><img src=\"images/cancel.png\" border=0></a></div>";

	//echo "<div align=\"right\"><a href=\"#\" onClick=\"overlayclose('hidden_form$formid'); return false\">Close</a></div>
	
	//echo "$formid<form>result from handler</form>";
	
	
	
	
	echo $response;
	
	
	//good bad buttons are not need for the user who just helped type in burmese
	/*<tr><td colspan=\"2\" align=center><button onclick=increase_good($formid);overlayclose('hidden_form$formid'); return false\">Good</button></td>
<td><button onclick=increase_bad($formid);overlayclose('hidden_form$formid'); return false\">Bad</button></td></tr>*/
	
}
else if($task == "r")
{
	//review
	
	$word = $_GET["w"];
	$def = $_GET["d"];
	$example = $_GET["e"];
	$author = $_GET["a"];
	$formid = $_GET["f"];
	
	//put the translated words in db **************
	
	//echo "we gonna put things in the db:\n$word,$def,$example,$author";
	//echo "";
	
	
	//$good_times = $_SESSION[$id."good"];
	
	
	//$code = print_hidden_from_with_value($word, $def, $example, $author,$formid);
	
	//$code = "fun";
	
	$decoded_word = burmese_special_char_decoder($word);
	$decoded_word = htmlspecialchars($decoded_word, ENT_QUOTES);
	
	$decoded_def = burmese_special_char_decoder($def);
	$decoded_def = htmlspecialchars($decoded_def, ENT_QUOTES);
	
	$decoded_example = burmese_special_char_decoder($example);
	$decoded_example = htmlspecialchars($decoded_example, ENT_QUOTES);
	
	$decoded_author = burmese_special_char_decoder($author);
	$decoded_author = htmlspecialchars($decoded_author, ENT_QUOTES);
	
	
	$response= "$formid<form onsubmit=\"overlayclose('hidden_form$formid');return false\">
<table border=0 width=320>
<tr><td colspan=\"2\" ><p class=textdark align=center>Like it?</p></td></tr>
<tr><td class=textdark width=20%>Word:</td><td class=textboxb>$decoded_word</input></td></tr>
<tr><td class=textdark>Definition:</td><td class=textareab>$decoded_def</textarea></td></tr>
<tr><td class=textdark>Example:</td><td class=textareab>$decoded_example</td></tr>
<tr><td class=textdark>Author:</td><td class=textboxb>$decoded_author</td></tr>
<input type=\"hidden\" id=w$formid value='$word'>
<input type=\"hidden\" id=d$formid value='$def'>
<input type=\"hidden\" id=e$formid value='$example'>
<input type=\"hidden\" id=a$formid value='$author'>
<tr><td colspan=\"2\" align=center><button onclick=back($formid);return false;\" class=button>Back</button>
<button onclick=insert_translated2($formid);change_image($formid);overlayclose('hidden_form$formid'); return false\" class=button>Submit</button></td></tr>
</table>
			</form><div align=\"right\"><a href=\"#\" onClick=\"overlayclose('hidden_form$formid'); return false\"><img src=\"images/cancel.png\" border=0></a></div>";

	//echo "<div align=\"right\"><a href=\"#\" onClick=\"overlayclose('hidden_form$formid'); return false\">Close</a></div>
	
	//echo "$formid<form>result from handler</form>";
	
	echo $response;
	//echo $formid."hell".$decoded_word;
	
}
else if($task=="g")
{
	$id = $_GET["f"];
	$word = $_GET["w"];
	$def = $_GET["d"];
	$example = $_GET["e"];
	$author = $_GET["a"];
	//increase good value
	add_one_click_to_session($id,"goodbad");
	
	$decoded_word = burmese_special_char_decoder($word);
	//$decoded_word = htmlspecialchars($decoded_word, ENT_QUOTES);
	
	$decoded_def = burmese_special_char_decoder($def);
	//$decoded_def = htmlspecialchars($decoded_def, ENT_QUOTES);
	
	$decoded_example = burmese_special_char_decoder($example);
	//$decoded_example = htmlspecialchars($decoded_example, ENT_QUOTES);
	
	$decoded_author = burmese_special_char_decoder($author);
	//$decoded_author = htmlspecialchars($decoded_author, ENT_QUOTES);
	
	
$response= "$id<form onsubmit=\"overlayclose('hidden_form$id');return false\">
<table border=0 width=300>
<tr><td colspan=\"2\" ><p class=textdark>Thanks for your input.</p></td></tr>
<tr><td class=textdark width=20%>Word:</td><td class=textdarkb>$decoded_word</input></td></tr>
<tr><td class=textdark>Definition:</td><td class=textdarkb>$decoded_def</textarea></td></tr>
<tr><td class=textdark>Example:</td><td class=textdarkb>$decoded_example</td></tr>
<tr><td class=textdark>Author:</td><td class=textdarkb>$decoded_author</td></tr>

</table>
			</form><div align=\"right\"><a href=\"#\" onClick=\"overlayclose('hidden_form$id'); return false\"><img src=\"images/cancel.png\" border=0></a></div>";

	
	
	if($_SESSION[$id."goodbad"]<= 1)
	{
		
	
		increase_good($id);
		$switch = approval_process($id);
		if($switch=="a")
		{
			$sqlresult = select_by_id($id);
			$r = mysql_fetch_array($sqlresult);
			
			//$code = "<p>hollda</p>";
			echo "a$id";
			print_result($decoded_word,$decoded_def,$decoded_example,$r['voteup'],$r['votedown'],$decoded_author,$id,"bur");
			//echo"<HID>";
			//print_hidden_original_innerHTML($id);
		}
		else
		{
			echo $response;
		}
		
	}
	else
	{
		echo "you've hit the limit";
	}
}
else if($task=="b")
{
$id = $_GET["f"];
	$word = $_GET["w"];
	$def = $_GET["d"];
	$example = $_GET["e"];
	$author = $_GET["a"];
	//increase good value
	add_one_click_to_session($id,"goodbad");
	
	$decoded_word = burmese_special_char_decoder($word);
	//$decoded_word = htmlspecialchars($decoded_word, ENT_QUOTES);
	
	$decoded_def = burmese_special_char_decoder($def);
	//$decoded_def = htmlspecialchars($decoded_def, ENT_QUOTES);
	
	$decoded_example = burmese_special_char_decoder($example);
	//$decoded_example = htmlspecialchars($decoded_example, ENT_QUOTES);
	
	$decoded_author = burmese_special_char_decoder($author);
	//$decoded_author = htmlspecialchars($decoded_author, ENT_QUOTES);
	
	
$response= "$id<form onsubmit=\"overlayclose('hidden_form$id');return false\">
<table border=0 width=300>
<tr><td colspan=\"2\" ><p class=textdark>Thanks for your opinion.</p></td></tr>
<tr><td class=textdark width=20%>Word:</td><td class=textdarkb>$decoded_word</input></td></tr>
<tr><td class=textdark>Definition:</td><td class=textdarkb>$decoded_def</textarea></td></tr>
<tr><td class=textdark>Example:</td><td class=textdarkb>$decoded_example</td></tr>
<tr><td class=textdark>Author:</td><td class=textdarkb>$decoded_author</td></tr>

</table>
			</form><div align=\"right\"><a href=\"#\" onClick=\"overlayclose('hidden_form$id'); return false\"><img src=\"images/cancel.png\" border=0></a></div>";

	
	
	if($_SESSION[$id."goodbad"]<= 1)
	{
		increase_bad($id);
	$switch = approval_process($id);
		if($switch=="a")
		{
			$sqlresult = select_by_id($id);
			$r = mysql_fetch_array($sqlresult);
			
			//$code = "<p>hollda</p>";
			echo "a$id";
			print_result($decoded_word,$decoded_def,$decoded_example,$r['voteup'],$r['votedown'],$decoded_author,$id,"bur");
			
		}
		else if($switch=="d")
		{
			echo "d$id"; //< is required for the javascript to extract teh $id
			print_hidden_form_innerHTML($id);
		}
		else
		{
			echo $response;
		}
		
	}
	else
	{
		echo "you've hit the limit";
	}
}
else if($task="get_code")
{
	$id = $_GET["f"];
	
	echo $id;
	print_hidden_original_innerHTML($id);
}
else
{
	echo " i didn't get it";
}












//echo "Welcome to the Jungle";

//print_burmese_layout();

?>